﻿// See https://aka.ms/new-console-template for more information
using System;
namespace Lesson1
{
    class primeCount
    {
        static void Main(string[] args)
        {
            int num1, numt, i, count = 0;
            //输入
            Console.WriteLine("请输入第一个数字作为上限");
            string str1 = Console.ReadLine();
            if (!int.TryParse(str1, out num1))
            {
                Console.WriteLine("输入的不是有效的整数，请重新输入数字。");
                return;
            } 
            Console.WriteLine("请输入第二个数字作为下限");
            string str2 = Console.ReadLine();
            int num2 = Convert.ToInt32(str2);

            if (num1 > num2)
            {
                for (numt = num2 + 1; numt < num1; numt++)
                {
                    //素数判断
                    for (i = 2; i < numt / 2; i++)
                    {
                        if (numt % i == 0)
                        {
                            break;
                        }
                        else if (i >= numt / 2 - 1)
                        {
                            count++;
                            //输出
                            if (count % 10 == 0)
                                Console.WriteLine("{0}", numt);
                            else Console.Write("{0}\t", numt);
                            break;
                        }
                    }
                }
            }
            else
            {
                Console.WriteLine("请输入正确的数字");
            }
        }

    }

}
